// 业务场景：
// 分别画一个红色的圆
// 一个黄色的圆
// 一个红色的三角
// 一个黄色的三角

// 非桥接模式
class ColorShape {
  yellowCircle() {
    console.log(`yellow circle`);
  }
  redCircle() {
    console.log(`red circle`);
  }
  yellowTriangle() {
    console.log(`yellow triangle`);
  }
  redTriangle() {
    console.log(`red triangle`);
  }
}
// 测试
let cs = new ColorShape();
cs.yellowCircle();
cs.redCircle();
cs.yellowTriangle();
cs.redTriangle();

// 桥接模式
class Color {
  constructor(name) {
    this.name = name;
  }
}
class Shape {
  constructor(name, color) {
    this.name = name;
    this.color = color;
  }
  draw() {
    console.log(`color: ${this.color.name}, name: ${this.name}`);
  }
}

// 测试代码
let red = new Color(`red`);
let yellow = new Color(`yellow`);
let circle = new Shape(`circle`, red);
circle.draw();
let triangle = new Shape(`triangle`, yellow);
triangle.draw();
